package com.etrans.web.gps.business.command.controller;

import com.etrans.egov.base.cmd.obj.CmdArgsPostQueryReq;
import com.etrans.egov.base.cmd.obj.CmdIds;
import com.etrans.egov.base.cmd.obj.ObjCmdReceipt;
import com.etrans.egov.base.cmd.obj.ObjCmdReply;
import com.etrans.egov.base.cmd.obj.ObjCmdRequest;

public class CommandUtil {

	Net2CmdProducer cmdProducer;
	
	public CommandUtil(String ipAddress,int port) {
		cmdProducer = new Net2CmdProducer(ipAddress, port);
		cmdProducer.start();
	}

	public void send(ObjCmdRequest cmdRequest) throws Exception{
		
		CmdArgsPostQueryReq cmdArgsPostQueryReq = new CmdArgsPostQueryReq();
		cmdArgsPostQueryReq.setGnssCenterId(1);
		cmdArgsPostQueryReq.setObjectType((byte)11);
		cmdArgsPostQueryReq.setObjectId("22");
		cmdArgsPostQueryReq.setInfoId(33);
		cmdArgsPostQueryReq.setInfoContent("44");
		
		ObjCmdRequest objCmd = new ObjCmdRequest();
		objCmd.setCmdId(CmdIds.CMD_ID_POST_QUERY_REQ);
//		objCmd.setArgs(cmdArgsPostQueryReq.toJSONString().toString());
		
		cmdProducer.push(objCmd, new Net2CmdProducer.Callback()
		{
			@Override
			public void onObjCmdReceipt(ObjCmdReceipt objCmdReceipt) throws Exception
			{
			}

			@Override
			public void onReceiptTimeout() throws Exception
			{
			}

			@Override
			public void onObjCmdReply(ObjCmdReply objCmdReply) throws Exception
			{
			}

			@Override
			public void onReplyTimeout() throws Exception
			{
			}
		});
	}
	
}
